﻿@{
    ViewBag.Title = "Index";
}
@using Projectmanagement.Entity
@using Projectmanagement.Utl
@model IQueryable<Project>
<style type="text/css">
    *
    {
        margin: 0;
        padding: 0;
    }
    a .img
    {
        border: none;
    }
    
    .arrowBox
    {
        width: 175px;
        float: left;
        margin-right: 20px;
    }
    .arrowPoint
    {
        overflow: hidden;
    }
    
    .pointBox
    {
        width: 175px;
        clear: both;
    }
    .point
    {
        overflow: hidden;
        float: left;
        height: 36px;
    }
    .task
    {
        float: left;
        width: 120px;
        font-size: 12px;
        line-height: 14px;
        text-align: left;
        padding-left: 15px;
        margin-top: 15px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-weight: bold;
        margin-left: -12px;
    }
    .arrow
    {
        width: 24px;
        overflow: hidden;
        clear: both;
    }
    .v_Task:link, .v_Task:visited
    {
        text-decoration: none;
        color: #333;
    }
    .v_Task:hover, .v_Task:active
    {
        color: #9B3126;
    }
    .nolineSp
    {
        width: 100%;
        border: 1px solid #aaaaaa;
        margin-top: 9px;
        font-family: "microsoft yaHei";
        color: #000;
    }
    .nolineSp tr, .nolineSp td
    {
        border: 0;
        padding: 2px;
    }
    
    .lcb{width:150px; height:36px; line-height:36px; color:#fff; background:url(../images/m_bg.jpg) no-repeat; overflow:hidden; padding-left:25px; font-size:12px; font-family:宋体}
</style>
<table class="nolineSp" id="tableRole">
    <tr>
        <td>
            <table style="width: 100%">
                <tr style="border-bottom: 1px solid #E8EEF4; background-color: #eee;">
                    <td style="width: 100%; border: 0">
                        <label for="searchProject">
                            <strong>项目：</strong></label>
                        <div id="projectContainer">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td style="height: 10px">
                    </td>
                </tr>
                <tr>
                    <td>
                        <div style="width: 300px; float: left">
                            <label for="startsWith">
                                <strong>成员：</strong></label>
                            @Html.DropDownList("searchMember", new[] { new SelectListItem() { Text = "-请选择-", Value = "" } }, new { style = "width:145px;" })
                        </div>
                        <div style="width: 460px; float: right; text-align: right; margin-right: 30px; font-size: 12px;">
                            <table style="border: 0;">
                                <tr>
                                    <td style="vertical-align: top;">
                                        <img src="../../images/Point2_green.png" />&nbsp;已完成
                                    </td>
                                    <td style="width: 10px">
                                    </td>
                                    <td style="vertical-align: top;">
                                        <img src="../../images/Point2_yellow.png" />&nbsp;请审核
                                    </td>
                                    <td style="width: 10px">
                                    </td>
                                    <td style="vertical-align: top;">
                                        <img src="../../images/Point2_blue.png" />&nbsp;进行中
                                    </td>
                                    <td style="width: 10px">
                                    </td>
                                    <td style="vertical-align: top;">
                                        <img src="../../images/Point2_red.png" />&nbsp;已过期
                                    </td>
                                    <td style="width: 10px">
                                    </td>
                                    <td style="vertical-align: top;">
                                        <img src="../../images/Point2_gray.png" />&nbsp;取消/失败
                                    </td>
                                    <td style="width: 10px">
                                    </td>
                                    <td style="vertical-align: top;">
                                        <img src="../../images/Point2_white.png" />&nbsp;未开始
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td style="height: 10px">
                    </td>
                </tr>
                <tr>
                    <td>
                        <div id="timelineContainer">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td style="height: 10px">
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
@(Html.Telerik().Window().Title("任务信息")
    .Name("TastMessage")
    .Content(@<text><div class="dialogue-TastMessage">
        <div class="TastMessage-wrapper">
        </div>
    </div></text>)
    .Width(1050)
    .Height(550)
    .Modal(true).Visible(false).Draggable(true)
)
<script type="text/javascript">
    function getprojects() {
        $.post('/Project/getprojects', { projectId: "" }, function (result) {
            $('#projectContainer').html(result);
            $(".searchProject").click(function () {
                freshTimeLine();
                selectMemberBind();
            });
            $("#searchMember").change(function () {
                freshTimeLine();
            });
        });
    }

    $(document).ready(function () {
        getprojects();
    });

    function freshTimeLine() {
        var sps;
        $('.searchProject').each(function () {
            if ($(this).attr('checked')) {
                if (sps) {
                    sps += ";" + $(this).val();
                }
                else {
                    sps = $(this).val();
                }
            }
        });
        $.ajax({
            url: 'TimeLine/freshTimeLine',
            type: 'GET',
            dataType: 'html',
            contentType: 'application/json; charset=utf-8',
            data: { searchProject: sps, searchMember: $('#searchMember').val() },
            success: function (result) {
                $('#timelineContainer').html(result);
            },
            error: function (xhr, status) {
                alert(xhr.responseText);
            }
        });
    }

    $(function () {
        getRole();
    });

    function selectMemberBind(id) {
        var sps;
        $('.searchProject').each(function () {
            if ($(this).attr('checked')) {
                if (sps) {
                    sps += ";" + $(this).val();
                }
                else {
                    sps = $(this).val();
                }
            }
        });
        var selec = sps;
        var url = "/TimeLine/GetSelectedProjectMember/";
        $("#searchMember").find("option").remove();
        $("<option></option>").val("").text("所有人员").appendTo($("#searchMember"));
        $.getJSON(url, { 'name': selec }, function (data) {
            if (data != null) {
                $.each(data, function (i, item) {
                    $("<option></option>").val(item["Value"]).text(item["Text"]).appendTo($("#searchMember"));
                });
                if (id == "") {

                }
                else {
                    $("#searchValue option[value='" + id + "']").attr("selected", true);
                }
            }
        });
    }
    function getRole() {
        var selec = "0";
        var url = "/TimeLine/GetRole/";
        $.post(url, { 'taskLineID': selec }, function (data) {
            if (data == "任务执行者") {
                $("#tdone").hide();
                $("#tdtwo").hide();
            }
            else {
                //$("#tableRole").show();
            }
        });
    }

    function showtask(id) {
        $.post('Task/GetDetail/', { taskid: id }, function (result) {
            $('.TastMessage-wrapper').html(result);
            var window = $('#TastMessage').data('tWindow');
            window.center().open();
        });
    }
</script>
